package com.example.wyz.classplus.ui.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import com.example.wyz.classplus.R;
import com.example.wyz.classplus.base.BaseActivity;
import com.example.wyz.classplus.contract.atv.CampusNoticeMsgContract;
import com.example.wyz.classplus.presenter.CampusNoticeMsgPresenter;
import com.example.wyz.classplus.ui.adapter.MainPagerAdapter;
import com.example.wyz.classplus.ui.fragment.CampusNoticeListFragment;
import com.example.wyz.classplus.ui.fragment.CounsellorNoticeListFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * Created by 10153 on 2017/5/29.
 */

public class CampusNoticeMsgActivity extends BaseActivity<CampusNoticeMsgContract.Presenter>
        implements CampusNoticeMsgContract.View{

    @BindView(R.id.mViewPager) ViewPager mViewPager;
    @BindView(R.id.mTabLayout) TabLayout mTabLayout;

    private MainPagerAdapter pagerAdapter;
    private List<Fragment> mFragments = new ArrayList<>();
    private String [] tabs = {"辅导员公告", "校园公告"};

    //BaseActivity方法重写&接口实现

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initViewPager();
        setHomeBtnEnable(true);
    }

    @Override
    protected int getLayout() {
        return R.layout.activity_msg_campus_notice;
    }

    @Override
    protected void initPresenter() {
        this.mPresenter = new CampusNoticeMsgPresenter(this, this);
    }

    //contract.view接口实现

    //私有方法

    private void initViewPager(){
        mFragments.add(new CounsellorNoticeListFragment());
        mFragments.add(new CampusNoticeListFragment());
        pagerAdapter = new MainPagerAdapter(this.getSupportFragmentManager(), mFragments, tabs);
        mViewPager.setAdapter(pagerAdapter);
        mTabLayout.setupWithViewPager(mViewPager);
    }
}
